﻿using Hidistro.Entities.Commodities;
using Hidistro.SaleSystem.Catalog;
using Hidistro.UI.SaleSystem.Tags;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using wnxd.Web;
using Hidistro.UI.Common.Controls;
using System.Web;
using System.Web.UI;

namespace Hidistro.UI.AccountCenter.CodeBehind
{
    public class BrowseRecord : MemberTemplatedWebControl
    {
        private wnxd_Shopping_LiList History;
        private IButton btnClearcookie;
        protected override void AttachChildControls()
        {
            this.btnClearcookie = ButtonManager.Create(this.FindControl("btnClearcookie"));
            this.btnClearcookie.Click += new EventHandler(this.btnClearcookie_Click);
            this.History = (wnxd_Shopping_LiList)this.FindControl("History");
            this.History.DataSource = this.GetHistory();
            this.History.DataBind();
            PageTitle.AddSiteNameTitle("浏览记录");
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "User/Skin-BrowseRecord.html";
            }
            base.OnInit(e);
        }
        private DataTable GetHistory()
        {
            IList<int> browedProductList = BrowsedProductQueue.GetBrowedProductList();
            if (browedProductList.Count == 0) return null;
            return ProductBrowser.GetVistiedProducts(browedProductList);
        }

        protected void btnClearcookie_Click(object sender, EventArgs e)
        {
            BrowsedProductQueue.ClearQueue();
            System.Web.HttpContext.Current.Response.Redirect("BrowseRecord.aspx");
        }
    }
}
